/*-----------------------------------------
file name  : rdy_generator.sv
created    : 2025/10/04 11:06:22
modified   : 2025-10-04 11:40:37
description: 
notes      : 
author     : yyrwkk
-----------------------------------------*/
`ifndef RDY_GENERATOR__SV
`define RDY_GENERATOR__SV
class rdy_generator extends uvm_component;
    rdy_configuration rdy_cfg;
    `uvm_component_utils(rdy_generator)

    uvm_blocking_get_imp#(rdy_trans,rdy_generator) to_rdy_driver_imp;
    extern function new( string name="rdy_generator" , uvm_component parent);
    
    extern function void build_phase(uvm_phase phase);
    extern task get(output rdy_trans tr);
endclass

function rdy_generator::new( string name="rdy_generator" , uvm_component parent);
    super.new(name,parent);
endfunction 

function rdy_generator::build_phase(uvm_phase phase);
    super.build_phase(phase);
    if( rdy_cfg == null ) begin 
        if( !uvm_config_db#(rdy_configuration)::get(this,"","rdy_cfg",rdy_cfg) )
            `uvm_warning("rdy_generator","get rdy_cfg from config_db failed!") 
        else begin 
            rdy_cfg = rdy_configuration::type_id::create("rdy_cfg");
            assert( rdy_cfg.randomize() )
            else `uvm_fatal("rdy_generator","rdy_cfg randomize failed!")
        end
    end

    to_rdy_driver_imp = new();
endfunction 

task rdy_generator::get(output rdy_trans tr);
    tr = new("tr");
    tr.set_cfg( rdy_cfg );
    assert( tr.randomize() )
    else `uvm_fatal("rdy_generator","randomize rdy_trans failed!")
endtask 

`endif

